package com.das.mechanic_base.adapter.main;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;

import androidx.recyclerview.widget.RecyclerView;
import com.das.mechanic_base.R;
import com.das.mechanic_base.bean.alone.DashboardWarnBean;


import java.util.ArrayList;
import java.util.List;

public class X3RecognitionStatusAdapter extends RecyclerView.Adapter<X3RecognitionStatusAdapter.RecognitionStatusHolder> {

    private Context mContext;

    private List<DashboardWarnBean.ElementsDTO> mList;
    public X3RecognitionStatusAdapter(Context mContext) {
        this.mContext = mContext;
        this.mList = new ArrayList<>();
    }

    public void setList(List<DashboardWarnBean.ElementsDTO> mList) {
        this.mList.clear();
        this.mList.addAll(mList);
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public X3RecognitionStatusAdapter.RecognitionStatusHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new RecognitionStatusHolder(LayoutInflater.from(mContext).inflate(R.layout.x3_main_recognition_status_item,parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull RecognitionStatusHolder holder, int position) {
//        holder.rl_item.setBackgroundResource(R.drawable.bg_recognition_one);
//        holder.rl_item.setBackgroundResource(R.drawable.x3_bg_recognition_two);
        holder.tv_name.setText(mList.get(position).className);
//        if(mList.get(position).label.equals("1")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_doorswindowsnotclosed);
//        } else if(mList.get(position).label.equals("2")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_notwearing );
//        }else if(mList.get(position).label.equals("3")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_frosttips );
//        }else if(mList.get(position).label.equals("4")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_cruisecontrol );
//        }else if(mList.get(position).label.equals("5")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_foglightson );
//        }else if(mList.get(position).label.equals("6")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_highbeamon );
//        }else if(mList.get(position).label.equals("7")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_rampassist );
//        }else if(mList.get(position).label.equals("8")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_glassheating );
//        }else if(mList.get(position).label.equals("9")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_brakeindicator );
//        }else if(mList.get(position).label.equals("10")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_fuelshortage );
//        }else if(mList.get(position).label.equals("11")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_lowtirepressure );
//        }else if(mList.get(position).label.equals("12")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_insufficientcleaningfluid );
//        }else if(mList.get(position).label.equals("13")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_batterydisadvantages );
//        }else if(mList.get(position).label.equals("14")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_needmaintenance );
//        }else if(mList.get(position).label.equals("15")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_abnormalwatertemperature );
//        }else if(mList.get(position).label.equals("16")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_oilalarmlamp );
//        }else if(mList.get(position).label.equals("17")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_insufficientcoolant );
//        }else if(mList.get(position).label.equals("18")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_brakediscwear );
//        }else if(mList.get(position).label.equals("19")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_safetyairbag );
//        }else if(mList.get(position).label.equals("20")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_enginefailure );
//        }else if(mList.get(position).label.equals("21")){
//            holder.iv_photo.setImageResource(R.mipmap.x3_others );
//        }

        if(position == mList.size()-1){
            holder.view_line.setVisibility(View.GONE);
        }else {
            holder.view_line.setVisibility(View.VISIBLE);
        }


    }



    @Override
    public int getItemCount() {
        return mList.size();
    }

    class RecognitionStatusHolder extends RecyclerView.ViewHolder {
        RelativeLayout rl_item;
        ImageView iv_photo;
        TextView tv_name;
        View view_type;
        View view_line;
        public RecognitionStatusHolder(@NonNull View itemView) {
            super(itemView);
            rl_item=itemView.findViewById(R.id.rl_item);
            iv_photo=itemView.findViewById(R.id.iv_photo);
            tv_name=itemView.findViewById(R.id.tv_name);
            view_type=itemView.findViewById(R.id.view_type);
            view_line=itemView.findViewById(R.id.view_line);
        }
    }
}
